<template>
    <div id='tmpl'>
    
        <div id="desc">
            <!--图片详情- 标题部分-->
            <div class="title">
                <h4>{{photoinfo.title}}</h4>
                <p>
                    {{photoinfo.add_time | dateformat('YYYY-MM-DD HH:mm:ss')}} {{photoinfo.click}}次浏览
                </p>
                <p class="line"></p>
            </div>
    
            <!--缩略图-->
            <div class="mui-content">
                <ul class="mui-table-view mui-grid-view mui-grid-9">
                    <li v-for="(item, index) in list" :key="index" class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
                        <img class="preview-img" :src="item.src" height="100" @click="$preview.open(index, list)">
                    </li>
                </ul>
            </div>
    
            <!--图片详情- 摘要部分-->
            <p v-html="photoinfo.content"></p>
        </div>
    
        <section id="comment">
            <comment :id="id">
            </comment>
        </section>
    </div>
</template>
<script>
import common from '../../kits/common.js';
import { Toast } from 'mint-ui';
import comment from '../subcom/comment.vue';
export default {
    components: {
        comment
    },
    data() {
        return {
            id: 0,
            photoinfo: {},
            list: []
        }
    },
    created() {
        this.id = this.$route.params.id;
        this.getinfo();
        this.getimgs();
    },
    methods: {
        getinfo() {
            let url = common.subdomain + '/api/getimageInfo/' + this.id;
            this.$http.get(url).then(function (res) {
                let data = res.body;
                if (data.status != 0) {
                    Toast(data.message);
                    return;
                }
                this.photoinfo = data.message[0];
            });
        },
        getimgs() {
            let url = common.subdomain + '/api/getthumimages/' + this.id;
            this.$http.get(url).then(function (res) {
                let data = res.body;
                if (data.status != 0) {
                    Toast(data.message);
                    return;
                }
                data.message.forEach(function (element) {
                    let img = document.createElement('img');
                    img.src = element.src;
                    element.h = img.height;
                    element.w = img.width;
                });
                this.list = data.message;
            })
        }
    }
}
</script>
<style lang="css" scoped>

</style>